<?php
/**
 * 文章推送 
 */
class Cli_ArticleController extends Ctrl_Cli{
    public function indexAction(){
        $tTime = time();
        $tMO = new ArticleModel; 
        $tDatas = $tMO->field('title,id,descriptions')->where('is_tui = 0 and status = 1 and push_time <= ' . $tTime)->fList();
        print_R($tDatas);
        if(!count($tDatas)){exit;}

        $tGMO = new GetuiModel;
        $tGDatas = $tGMO->field('devicetoken,cid')->fList();
		$tRedis = Cache_Redis::instance();

        foreach($tDatas as $tRow){

            foreach($tGDatas as $tR){
                $tRes = serialize(array_merge($tRow,$tR,array('type'=>'article','content'=>'')));  
                $tRedis->lpush('dkdoctor_getui',$tRes);	
            }
            
            $tData = array(
                'is_tui' => 1, 
                'id' => $tRow['id']
            );
            $tMO->update($tData);
        }
        exit;
    }


}
